import { put } from "redux-saga/effects";

function* interceptError(creator, response) {
  console.log("request failure response====>", response);

  let error = "发生错误";
  if (response?.data?.message) {
    error = response.data.message;
    yield put(creator(response.data.message));
    return error;
  }
  yield put(creator(error));
  return error;
}

export default interceptError;
